<%@page import="com.office.automate.configuration.property.ConfigurationProperties"%>
<%@page import="java.util.Properties"%>
<%@page import="java.text.SimpleDateFormat"%>
<%@page import="com.office.automate.service.impl.report.ReportingServiceImplementer"%>
<%@page import="com.office.automate.model.report.EmployeeLeaveDetailsRequest"%>
<%@page import="com.office.automate.model.leave.LeaveRequest"%>
<%@page import="java.util.List"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<%@ include file="../common/CommonHeaderInfo.jsp"%>
<title>Employee Leave</title>
</head>
<body>
	<%@ include file="../common/SiteHeaderSection.jsp" %>
	<%@ include file="../common/MainMenuBar.jsp"%>

<%
	if (currentUser == null) {
		return;
	}
	Properties configSeqPropspg = ConfigurationProperties.getProps(); 
	Utility utilpg = new Utility(currentUser.getSecurityLevels());
	if (!utilpg.isFunctionalSecurityAllow(configSeqPropspg.getProperty("MAIN_REPORTING")) ||  
				!utilpg.isFunctionalSecurityAllow(configSeqPropspg.getProperty("REPORT_LEAVE_DETAILS")))  {
		response.sendRedirect("/OfficeAutomation/jsp/HomePage.jsp");
	}	
	EmployeeLeaveDetailsRequest submitResult = (EmployeeLeaveDetailsRequest) request.getAttribute("RequestDetails");
	List<LeaveRequest> leaveRequestsList = new ReportingServiceImplementer().getEmployeeLeaveDetails(submitResult);
	SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
	Properties properties = ConfigurationProperties.getProps();
%>
<tr>
	<td>
	  <center>
			<h2>Employee Leave Detail Report</h2>
			<table class="reportgridstyle">
				<tr class="grid-heding-row-style">
		
					<th class="grid-heding-cell-style">Employee Id</th>
					<th class="grid-heding-cell-style">Financial Year</th>
					<th class="grid-heding-cell-style">Leave Type</th>
					<th class="grid-heding-cell-style">From Date</th>
					<th class="grid-heding-cell-style">To Date</th>
					<th class="grid-heding-cell-style">Status</th>
			
				</tr>
			<%
			  if (leaveRequestsList.size() > 0) {
				  int i = 0;
				for (LeaveRequest leaveRequest: leaveRequestsList) {
			%>	
					<tr <% if (i%2 == 0) { %> class="data-row-even-style" <% } else { %> class="data-row-odd-style" <% } %> >
		
						<td class="data-row-cell-style"><%=leaveRequest.getEmployeeId() %></td>
						<td class="data-row-cell-style"><%=leaveRequest.getFinancialYear() %></td>
						<td class="data-row-cell-style"><%=leaveRequest.getLeaveType() %></td>
						<td class="data-row-cell-style"><%=formatter.format(leaveRequest.getFromDate()) %></td>
						<td class="data-row-cell-style"><%=formatter.format(leaveRequest.getToDate()) %></td>
						<td class="data-row-cell-style"><%=properties.getProperty(leaveRequest.getStatus()) %></td>
					</tr>
			<%
				}
			  } else {
			%>
		
			<%
			  }
			%>
			</table>
			<a href="/OfficeAutomation/jsp/report/LeaveApplyDetailsSubmitReport.jsp">Back</a>
		 </center>
	</td>
</tr>
		
<%@ include file="../common/SiteFotterSection.jsp" %>
</body>
</html>